<?php
namespace Admin\Controller;
use Think\Controller;
class ToolController extends AdminController {
    public function index(){
    	
    }
    //前台页脚页面
    public function qfooter_page(){
    	$this->q=M('qfooter')->find();
    	$this->display();
    }
    //修改前台页脚
    public function qfooter(){
    	$data['content']=I('content');
    	if(M('qfooter')->where('id=1')->save($data)){
    		$this->ajaxReturn(V(1,'修改成功'));
    	}else{
    		$this->ajaxReturn(V(2,'修改失败'));
    	}
    }
    //轮播图
    public function banner(){
        $this->banner=M('banner')->select();
    	$this->display();
    }
    //轮播图添加页面
    public function add_banner_page(){
        $this->display();
    }
    //添加轮播
    public function add_banner(){
        $data['image']=I('image');
        $data['beizhu']=I('beizhu');
        $data['time']=time();
        if(M('banner')->add($data)){
            $this->ajaxReturn(V(1,'添加成功'));
        }else{
            $this->ajaxReturn(V(2,'添加失败'));
        }
    }
    //修改轮播页面
    public function save_banner_page(){
        $id=I('id');
        $this->b=M('banner')->where("id='$id'")->find();
        $this->assign('id',$id);
        $this->display();
    }
    //修改轮播
    public function save_banner(){
        $id = I('id');
        $data['image']=I('image');
        $data['beizhu']=I('beizhu');
        $data['time']=time();
        if(M('banner')->where("id='$id'")->save($data)){
            $this->ajaxReturn(V(1,'修改成功'));
        }else{
            $this->ajaxReturn(V(2,'修改失败'));
        }
    }
    //删除轮播
    public function del_banner(){
        $id = I('id');
        if(M('banner')->where("id='$id'")->delete()){
            $this->ajaxReturn(V(1,'删除成功'));
        }else{
            $this->ajaxReturn(V(2,'删除失败'));
        }
    }
}